<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/6/23
 * Time: 15:24
 * Project name: PHPTEST
 * File name: 5.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license https://github.com/zhangrxiang
 * @since 1.0.0
 */

// 将文本中的年份增加一年.
$text = "April fools day is 04/01/2002\n";
$text .= "Last christmas was 12/24/2001\n";
// 回调函数
function next_year( $matches ) {
	// 通常: $matches[0]是完成的匹配
	// $matches[1]是第一个捕获子组的匹配
	// 以此类推
	print_r($matches);
	echo PHP_EOL;
	return $matches[1] . ( $matches[2] + 1 );
}

echo preg_replace_callback(
	'|(\d{2}/\d{2}/)(\d{4})|',
	"next_year",
	$text );


echo mb_convert_encoding("卧槽", "UTF-8", "HTML-ENTITIES" );